package com.changli09._enum;

public class SeasonTest1 {
    public static void main(String[] args) {
//        //1.默认是 ToString()方法
//        System.out.println(Season1.SPRING);
////        2.name()方法
//        System.out.println(Season1.SUMMER.name());
////        3.value() 将所有的对象 放入一个数组
//        Season1 [] s = Season1.values();
//        for (int i = 0; i < s.length; i++) {
//            System.out.println(s[i]);
//        }
////        4.valueOf(str) 寻找 str 对应的对象
//        String str= "WINTER";
//        System.out.println(Season1.valueOf(str));
////        5.ordinal()返回对应对象的次序
//        System.out.println(Season1.SUMMER.ordinal());
        Season1.SUMMER.show();
        Season1[] values = Season1.values();
        for (int i = 0; i < values.length; i++) {
            values[i].show();

        }
    }
}
interface showSeason {
    public void show();
}
enum Season1 implements showSeason {
//    1.必须在枚举类的开头声明多个对象。对象之间使用,隔开
    SPRING ("春天", "春暖花开"){
        public void show() {
            System.out.println("春天在哪里");
        }
},
    SUMMER("夏天","夏日炎炎"){
        public void show() {
            System.out.println("夏天在哪里");
        }
    },
    AUTUMN("秋天","秋高气爽"){
        public void show() {
            System.out.println("秋天在哪里");
        }
    },
    WINTER( "冬天","白雪皑皑"){
        public void show() {
            System.out.println("冬天在哪里");
        }
    };
    //2.声明当前类的对象的实例变量,使用private final修饰
    private String seasonName;
    private String seasonDesc;
    //3.私有化类的构造器
    private Season1(String seasonName, String seasonDesc) {
        this.seasonName = seasonName;
        this.seasonDesc = seasonDesc;
    }
    //4.提供实例变量的get方法
    public String getSeasonName() {
        return seasonName;
    }

    public void setSeasonName(String seasonName) {
        this.seasonName = seasonName;
    }

    public String getSeasonDesc() {
        return seasonDesc;
    }

    public void setSeasonDesc(String seasonDesc) {
        this.seasonDesc = seasonDesc;
    }

    @Override
    public String toString() {
        return "Season{" +
                "seasonName='" + seasonName + '\'' +
                ", seasonDesc='" + seasonDesc + '\'' +
                '}';
    }

}
